package no21.thread;

import java.util.concurrent.TimeUnit;

public class Liftoff implements Runnable {

	protected int countDown = 10;
	private static int taskCount = 0;
	private final int id = taskCount++;

	public Liftoff() {
		
	}

	public Liftoff(int countDown) {
		this.countDown = countDown;
	}

	public String status() {
		return "#" + id + "(" + (countDown > 0 ? countDown : "Liftoff!") + "),";
	}

	public void run() {
		while (countDown-- > 0) {
			System.out.println(status());
			/**
			try {
				//休眠100ms
				TimeUnit.MILLISECONDS.sleep(100);
				//设置优先级
				Thread.currentThread().setPriority(1);
				//取得优先级
				Thread.currentThread().getPriority();
				
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			*/
			//线程让步
			Thread.yield();
		}
	}

}
